from app.service.ali import Ali
from app.service.wx import WxPay
from libs.common import success


def query_pay_state(request):
    order_sn = request.GET.get('order_sn', default='')
    typ = request.GET.get('typ', default='wx')
    if typ == 'wx':
        traded_no, trade_state, res, err = WxPay().queryOrder(order_sn)
    else:
        traded_no, trade_state, res, err = Ali().queryOrder(order_sn)
    return success(traded_no=traded_no, trade_state=trade_state, res=res, err=err)
